package com.artPreter.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.artPreter.pojo.Artist;
import com.artPreter.pojo.Depart;

import com.artPreter.pojo.Result;
import com.artPreter.pojo.dto.ArtistName;
import com.artPreter.service.IArtistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 艺术家表 前端控制器
 * </p>
 *
 * @author jarvis
 * @since 2024-11-14
 */
@RestController
@RequestMapping("/artist")
public class ArtistController {

    @Autowired
    private IArtistService artistService;

    /**
     * 艺术家分页
     * @param currentPage
     * @param size
     * @param artist
     * @return
     */
    @PostMapping("/getPage")
    public Result getPage(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artist artist){
        IPage<Artist> departIPage = artistService.getPage(currentPage,size,artist);
        return Result.success(departIPage);
    }

    /**
     * 艺术家分页带艺术机构
     * @param currentPage
     * @param size
     * @param artist
     * @return
     */
    @PostMapping("/getPageWithDepart")
    public Result getPageWithDepart(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artist artist){
        IPage<Artist> departIPage = artistService.getPageWithDepart(currentPage,size,artist);
        return Result.success(departIPage);
    }

    /**
     * 添加艺术家
     * @param artist
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody Artist artist){
        artistService.add(artist);
        return Result.success();
    }

    /**
     * 修改艺术机构
     * @param artist
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody Artist artist){
        artistService.edit(artist);
        return Result.success();
    }

    /**
     * 软删除艺术机构
     * @param artist
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Artist artist){
        artistService.delete(artist);
        return Result.success();
    }

    /**
     * 获取字母排序艺术家列表
     * @param artist
     * @return
     */
    @PostMapping("/getListByFirstPy")
    public Result getListByFirstPy(@RequestBody Artist artist){
        List<ArtistName> list = artistService.getListByFirstPy(artist);
        return Result.success(list);
    }


    /**
     * 添加到图片关联表
     * @param
     * @return
     */
    @PostMapping("/addToRelative")
    public Result addToRelative(@RequestBody Artist artist){
        artistService.addToRelative(artist);
        return Result.success();
    }

    /**
     * 删除关联图片
     * @param
     * @return
     */
    @PostMapping("/removeArtistRelative")
    public Result removeArtistRelative(@RequestBody Artist artist){
        artistService.removeArtistRelative(artist);
        return Result.success();
    }

    /**
     * 围观关联图片分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPageNoRelative")
    public Result getPageNoRelative(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artist artist){
        IPage<Artist> artistIPage = artistService.getPageNoRelative(currentPage,size,artist);
        return Result.success(artistIPage);
    }

    /**
     * 已关联艺术家分页
     * @param currentPage
     * @param size
     * @param
     * @return
     */
    @PostMapping("/getPageRelative")
    public Result getPageRelative(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage, @RequestParam(value = "size",defaultValue = "10") Integer size, @RequestBody Artist artist){
        IPage<Artist> artistIPage = artistService.getPageRelative(currentPage,size,artist);
        return Result.success(artistIPage);
    }

    @PostMapping("/save/depart/sort")
    public Result saveDepartRelativeSort(@RequestBody List<Artist> artistList){
        artistService.saveDepartRelativeSort(artistList);
        return Result.success();
    }

    /**
     * 查询艺术家构详情
     * @param
     * @return
     */
    @PostMapping("/getInfo")
    public Result getInfo(@RequestBody Artist artist){
        Artist result = artistService.getInfo(artist);
        return Result.success(result);
    }



}
